package service.Impl;

import com.alibaba.fastjson.JSON;
import mapper.Impl.ProvinceMapperImpl;
import mapper.ProvinceMapper;
import pojo.City;
import pojo.Province;
import service.ProvinceService;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

public class ProvinceServiceImpl implements ProvinceService {

    private ProvinceMapper provinceMapper = new ProvinceMapperImpl();

    @Override
    public String getProvinces() {

        List<Province> provinces = provinceMapper.getProvinces();
        String jsonStr = JSON.toJSONString(provinces);
        return jsonStr;
    }

    @Override
    public String getCities(HttpServletRequest request) {
        //获取省份的code
        String code = request.getParameter("code");
        List<City> cities = provinceMapper.getCities(code);
        String jsonStr = JSON.toJSONString(cities);
        return jsonStr;
    }
}
